home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Utilities / vim-5.1 / src / testdir / test3.in < prev    next >
Encoding:
Text File  |  1998-03-08  |  6.4 KB  |  613 lines

  1. /* vim: set cin ts=4 sw=4 : */
  2.  
  3. Test for 'cindent'
  4.  
  5. STARTTEST
  6. :set nocompatible
  7. :edit                " read modeline
  8. /start of AUTO
  9. =/end of AUTO
  10. ENDTEST
  11.  
  12. /* start of AUTO matically checked */
  13. {
  14.     if (test)
  15.         cmd1;
  16.     cmd2;
  17. }
  18.  
  19. {
  20.     if (test)
  21.         cmd1;
  22.     else
  23.         cmd2;
  24. }
  25.  
  26. {
  27.     if (test)
  28.     {
  29.         cmd1;
  30.         cmd2;
  31.     }
  32. }
  33.  
  34. {
  35.     if (test)
  36.     {
  37.         cmd1;
  38.         else
  39.     }
  40. }
  41.  
  42. {
  43.     while (this)
  44.         if (test)
  45.             cmd1;
  46.     cmd2;
  47. }
  48.  
  49. {
  50.     while (this)
  51.         if (test)
  52.             cmd1;
  53.         else
  54.             cmd2;
  55. }
  56.  
  57. {
  58.     if (test)
  59.     {
  60.         cmd;
  61.     }
  62.  
  63.     if (test)
  64.         cmd;
  65. }
  66.  
  67. {
  68.     if (test) {
  69.         cmd;
  70.     }
  71.  
  72.     if (test) cmd;
  73. }
  74.  
  75. {
  76.     cmd1;
  77.     for (blah)
  78.         while (this)
  79.             if (test)
  80.                 cmd2;
  81.     cmd3;
  82. }
  83.  
  84. {
  85.     cmd1;
  86.     for (blah)
  87.         while (this)
  88.             if (test)
  89.                 cmd2;
  90.     cmd3;
  91.  
  92.     if (test)
  93.     {
  94.         cmd1;
  95.         cmd2;
  96.         cmd3;
  97.     }
  98. }
  99.  
  100.  
  101. /* Test for 'cindent' do/while mixed with if/else: */
  102.  
  103. {
  104.     do
  105.         if (asdf)
  106.             asdfasd;
  107.     while (cond);
  108.  
  109.     do
  110.         if (asdf)
  111.             while (asdf)
  112.                 asdf;
  113.     while (asdf);
  114. }
  115.  
  116. /* Test for 'cindent' with two ) on a continuation line */
  117. {
  118.     if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
  119.             aal;sdkjf  ( ;asldfkja;sldfk
  120.                     al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
  121.         line up here;
  122. }
  123.  
  124.  
  125. /* C++ tests: */
  126.  
  127. // foo()        these three lines should remain in column 0
  128. // {
  129. // }
  130.  
  131. /* Test for continuation and unterminated lines: */
  132. {
  133.     i = 99 + 14325 +
  134.         21345 +
  135.         21345 +
  136.         21345 + ( 21345 +
  137.                 21345) +
  138.         2345 +
  139.         1234;
  140.     c = 1;
  141. }
  142.  
  143. /*
  144.    testje for indent with empty line
  145.  
  146.    here */
  147.  
  148. {
  149.     if (testing &&
  150.             not a joke ||
  151.             line up here)
  152.         hay;
  153.     if (testing &&
  154.             (not a joke || testing
  155.             )line up here)
  156.         hay;
  157.     if (testing &&
  158.             (not a joke || testing
  159.              line up here))
  160.         hay;
  161. }
  162.  
  163.  
  164. {
  165.     switch (c)
  166.     {
  167.         case xx:
  168.             do
  169.                 if (asdf)
  170.                     do
  171.                         asdfasdf;
  172.                     while (asdf);
  173.                 else
  174.                     asdfasdf;
  175.             while (cond);
  176.         case yy:
  177.         case xx:
  178.         case zz:
  179.             testing;
  180.     }
  181. }
  182.  
  183. {
  184.     if (cond) {
  185.         foo;
  186.     }
  187.     else
  188.     {
  189.         bar;
  190.     }
  191. }
  192.  
  193. {
  194.     if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
  195.             alsdkfj (asldk;fj
  196.                     awith cino=(0 ;lf this one goes to below the paren with ==
  197.                             ;laksjfd ;lsakdjf ;alskdf asd)
  198.                     asdfasdf;)))
  199.         asdfasdf;
  200. }
  201.  
  202.     int
  203. func(a, b)
  204.     int a;
  205.     int c;
  206. {
  207.     if (c1 && (c2 ||
  208.             c3))
  209.         foo;
  210.     if (c1 &&
  211.             (c2 || c3)
  212.        )
  213. }
  214.  
  215. {
  216.     while (asd)
  217.     {
  218.         if (asdf)
  219.             if (test)
  220.                 if (that)
  221.                 {
  222.                     if (asdf)
  223.                         do
  224.                             cdasd;
  225.                         while (as
  226.                                 df);
  227.                 }
  228.                 else
  229.                     if (asdf)
  230.                         asdf;
  231.                     else
  232.                         asdf;
  233.         asdf;
  234.     }
  235. }
  236.  
  237. {
  238.     s = "/*"; b = ';'
  239.         s = "/*"; b = ';';
  240.     a = b;
  241. }
  242.  
  243. {
  244.     switch (a)
  245.     {
  246.         case a:
  247.             switch (t)
  248.             {
  249.                 case 1:
  250.                     cmd;
  251.                     break;
  252.                 case 2:
  253.                     cmd;
  254.                     break;
  255.             }
  256.             cmd;
  257.             break;
  258.         case b:
  259.             {
  260.                 int i;
  261.                 cmd;
  262.             }
  263.             break;
  264.         case c: {
  265.                     int i;
  266.                     cmd;
  267.                 }
  268.         case d: if (cond &&
  269.                         test) {        /* this line doesn't work right */
  270.                     int i;
  271.                     cmd;
  272.                 }
  273.                 break;
  274.     }
  275. }
  276.  
  277. {
  278.     if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
  279.             (bp_to->b_p_initialized ||
  280.              (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
  281.         return;
  282. label :
  283.     asdf = asdf ?
  284.         asdf : asdf;
  285.     asdf = asdf ?
  286.         asdf: asdf;
  287. }
  288.  
  289. /* Special Comments    : This function has the added complexity (compared  */
  290. /*                    : to addtolist) of having to check for a detail     */
  291. /*                    : texture and add that to the list first.             */
  292.  
  293. char *(array[100]) = {
  294.     "testje",
  295.     "foo",
  296.     "bar",
  297. }
  298.  
  299. {
  300.     struct Type
  301.     {
  302.         int i;
  303.         char *str;
  304.     } var[] =
  305.     {
  306.         0, "zero",
  307.         1, "one",
  308.         2, "two",
  309.         3, "three"
  310.     };
  311.  
  312.     float matrix[3][3] =
  313.     {
  314.         {
  315.             0,
  316.             1,
  317.             2
  318.         },
  319.         {
  320.             3,
  321.             4,
  322.             5
  323.         },
  324.         {
  325.             6,
  326.             7,
  327.             8
  328.         }
  329.     };
  330. }
  331.  
  332. {
  333.     /* blah ( blah */
  334.     /* where does this go? */
  335.  
  336.     /* blah ( blah */
  337.     cmd;
  338.  
  339.     func(arg1,
  340.             /* comment */
  341.             arg2);
  342.     a;
  343.     {
  344.         b;
  345.         {
  346.             c; /* Hey, NOW it indents?! */
  347.         }
  348.     }
  349.  
  350.     {
  351.         func(arg1,
  352.                 arg2,
  353.                 arg3);
  354.         /* Hey, what am I doing here?  Is this coz of the ","? */
  355.     }
  356. }
  357.  
  358. main ()
  359. {
  360.     if (cond)
  361.     {
  362.         a = b;
  363.     }
  364.     if (cond) {
  365.         a = c;
  366.     }
  367.     if (cond)
  368.         a = d;
  369.     return;
  370. }
  371.  
  372. {
  373.     case 2: if (asdf &&
  374.                     asdfasdf)
  375.                 aasdf;
  376.             a = 9;
  377.     case 3: if (asdf)
  378.                 aasdf;
  379.             a = 9;
  380.     case 4:    x = 1;
  381.                y = 2;
  382.  
  383. label:    if (asdf)
  384.             here;
  385.  
  386. label:  if (asdf &&
  387.                 asdfasdf)
  388.         {
  389.         }
  390.  
  391. label:  if (asdf &&
  392.                 asdfasdf) {
  393.             there;
  394.         }
  395.  
  396. label:  if (asdf &&
  397.                 asdfasdf)
  398.             there;
  399. }
  400.  
  401. {
  402.     /*
  403.        hello with ":set comments= cino=c5"
  404.      */
  405.  
  406.     /*
  407.        hello with ":set comments= cino="
  408.      */
  409. }
  410.  
  411.  
  412. {
  413.     if (a < b) {
  414.         a = a + 1;
  415.     } else
  416.         a = a + 2;
  417.  
  418.     if (a)
  419.         do {
  420.             testing;
  421.         } while (asdfasdf);
  422.     a = b + 1;
  423.     asdfasdf
  424. }
  425.  
  426. class bob
  427. {
  428.     int foo() {return 1;}
  429.         int bar;
  430. }
  431.  
  432. main()
  433. {
  434. while(1)
  435. if (foo)
  436. {
  437. bar;
  438. }
  439. else {
  440. asdf;
  441. }
  442. misplacedline;
  443. }
  444.  
  445. {
  446.     if (clipboard.state == SELECT_DONE
  447.     && ((row == clipboard.start.lnum
  448.     && col >= clipboard.start.col)
  449.     || row > clipboard.start.lnum))
  450. }
  451.  
  452. /* end of AUTO */
  453.  
  454. STARTTEST
  455. :set tw=0 wm=60 columns=80 noai fo=croq
  456. /serious/e
  457. a about life, the universe, and the rest
  458. ENDTEST
  459.  
  460. {
  461.  
  462. /* this is
  463.  * a real serious important big
  464.  * comment
  465.  */
  466.     /* insert " about life, the universe, and the rest" after "serious" */
  467. }
  468.  
  469. STARTTEST
  470. :set nocin
  471. /comments
  472. joabout life/happens
  473. jothere/below
  474. oline/this
  475. Ohello
  476. ENDTEST
  477.  
  478. {
  479.     /*
  480.      * Testing for comments, without 'cin' set
  481.      */
  482.  
  483. /*
  484. * what happens here?
  485. */
  486.  
  487.     /*
  488.        the end of the comment, try inserting a line below */
  489.  
  490.         /* how about
  491.                         this one */
  492. }
  493.  
  494. STARTTEST
  495. :set cin
  496. /vec2
  497. ==
  498. ENDTEST
  499.  
  500. {
  501.     var = this + that + vec[0] * vec[0]
  502.                       + vec[1] * vec[1]
  503.                       + vec2[2] * vec[2];
  504. }
  505.  
  506. STARTTEST
  507. :set cin
  508. :set cino=}4
  509. /testing1
  510. k2==/testing2
  511. k2==
  512. ENDTEST
  513.  
  514. {
  515.         asdf asdflkajds f;
  516.     if (tes & ting) {
  517.         asdf asdf asdf ;
  518.         asdfa sdf asdf;
  519.         }
  520.     testing1;
  521.     if (tes & ting)
  522.     {
  523.         asdf asdf asdf ;
  524.         asdfa sdf asdf;
  525.         }
  526.     testing2;
  527. }
  528.  
  529. STARTTEST
  530. :set cin
  531. :set cino=(0,)20
  532. /main
  533. =][
  534. ENDTEST
  535.  
  536. main ( int first_par, /*
  537.                        * Comment for
  538.                        * first par
  539.                        */
  540.           int second_par /*
  541.                        * Comment for
  542.                        * second par
  543.                        */
  544.      )
  545. {
  546.     func( first_par, /*
  547.                       * Comment for
  548.                       * first par
  549.                       */
  550.     second_par /*
  551.                       * Comment for
  552.                       * second par
  553.                       */
  554.         );
  555.  
  556. }
  557.  
  558. STARTTEST
  559. :set cin
  560. :set cino=
  561. ]]=][
  562. ENDTEST
  563.  
  564. {
  565.     do
  566.     {
  567.         if ()
  568.         {
  569.             if ()
  570.                 asdf;
  571.             else
  572.                 asdf;
  573.         }
  574.     } while ();
  575.             cmd;        /* this should go under the } */
  576. }
  577.  
  578. STARTTEST
  579. ]]=][
  580. ENDTEST
  581.  
  582. void f()
  583. {
  584.     if ( k() ) {
  585.         l();
  586.  
  587.     } else { /* Start (two words) end */
  588.         m();
  589.     }
  590.  
  591.     n();
  592. }
  593.  
  594. STARTTEST
  595. /while
  596. ohere
  597. ENDTEST
  598.  
  599. a()
  600. {
  601.   do {
  602.     a = a +
  603.       a;
  604.   } while ( a );        /* add text under this line */
  605.     if ( a )
  606.       a;
  607. }
  608.  
  609. STARTTEST
  610. :1;/ENDTEST/+1,$wq! test.out
  611. ENDTEST
  612.  
  613.